﻿using System;
using System.Linq;
using NeuralLib.ActivationFunction;

namespace NeuralLib
{
    public enum ENeuronType { NtInput, NtOutput, NtHidden };

    public class DisconnectedNeuron
    {
        public int Id;

        public ENeuronType Type { get; set; }

        public bool IsActivated = false;

        public DisconnectedNeuron(int id, IActivationFunction function, ENeuronType type)
        {
            Id = id;
            Function = function;
            Type = type;
        }

        public IActivationFunction Function;

        public double Output;

        public double Compute(double[] inputs, double[] weights)
        {
            double output = 0;
            if (inputs.Count()!=weights.Count())
                throw  new ArgumentException("inputs and weights shoud be the same size!");
            for (var i = 0; i < inputs.Count(); i++)
                output += weights[i]*inputs[i];
            Output = Function.Function(output);
            IsActivated = true;
            return Output;
        }
    }
}